1. Field
The following description relates to a virtual machine that uses a just-in-time compiler (JITC) as a software execution environment.
2. Description of the Related Art
A virtual machine may be used to run an application in a device that is equipped with heterogeneous central processing units (CPUs) and memories.
Code that is written in a high-level language may be distributed, for example, as a script or as hardware-independent intermediate code. The code may be executed by the interpreters or the machine language translators of virtual machines that are installed in various devices.
Examples of a virtual machine include a JAVA® virtual machine, which is widely used in mobile phones, digital TVs, and the like. Other examples include JAVASCRIPT® which is code that may be transmitted via the web, a DALVIK® virtual machine, and the like.
Various applications may be run in various embedded devices such as mobile phones, digital TVs, servers, desktops, and the like, using virtual machines. Bytecode is generally distributed as execution code for a virtual machine to be run in diverse execution environments. The distributed bytecode may be executed by an interpreter. However, in executing bytecode, the interpreter is slower than when executing machine code. To prevent such a drawback and increase execution speed, a just-in-time compiler (JITC) may be utilized.
For example, the JITC may compile bytecode that is currently being executed into machine code, store the machine code in code cache of a virtual machine, and utilize the stored machine code while executing the compiled bytecode. The JITC may track a path from a certain position of bytecode in the course of running virtual machine, and generate machine code that corresponds to a predefined length of a bytecode trace.
The bytecode trace may be a segment of code of a predefined length of bytecode. The bytecode trace may prevent consumption of a large amount of time and/or the generation of an excessive amount of machine codes in the JITC.
In a tracking scheme, bytecode is executive in logically consecutive order, however, the order for a JITC to compile bytecode traces may not always follow the logical order for executing the bytecode.
Machine code generated by the JITC may be stored in a code cache of the virtual machine, and even when the bytecode is consecutive, the machine code may be stored in an inconsecutive manner if the machine code is generated at different times by the JITC.
Additionally, if the stored machine code has an increase in the number of jump instructions attached thereto, and if the length of each bytecode trace is short, the number of machine codes to be stored increases, and thus, the performance of the code cache may deteriorate.